﻿<?php 
$db = mysql_connect ("localhost","igor","igor");
mysql_select_db ("simple blog");
if(isset($_POST['text'])) {$text = $_POST['text'];}
if(isset($_POST['author'])) {$author = $_POST['author'];}
if(isset($_POST['id'])) {$id = $_POST['id'];}





?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ОБРАБОТЧИК1</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="79" border="0" align="center" cellpadding="0" cellspacing="0" class="main_border">
  <tr>
    <td><a href='index.php'><img src="img/header-woman.jpg" width="960" height="200" /></a></td>
  </tr>
  <tr>
    <td height="29" align="center" valign="top" bgcolor="#B0C4DE">
    <p class="ls"><a href="view_article.php?id=<?php echo $id ?>">Обратно к записи</a></p>

	
         <?php
        $this_date=date('Y-m-d');
		$title_error = null;
        if (trim($author)=='' ){
            $author = 'Аноним'; }

        $text_error = null;
         if (strlen($text) > 200)

           {$text_error = "Пожалуйста уменьшите длину записи, максимальная длина: 100 символов! ";}

        if ($text_error!= null){
            require ("error_comment.php");
        }
        else {

        $sql = sprintf("INSERT INTO coments (text,date,author,main_id) VALUES ('%s','%s','%s','%s')", mysql_real_escape_string($text),mysql_real_escape_string($this_date),mysql_real_escape_string($author),mysql_real_escape_string($id));
            $result=mysql_query ($sql);
        if ($result = true) {  header ('Location: view_article.php?id=' . $id);}
	   else { echo "Ваше сообщение не было добавлено";}
	   
        }
	 
	 ?>  
          
          
          
          
         
    <p>&nbsp;</p></td>
  </tr>
  <tr>
    <td><img src="img/iuh.jpg" width="960" height="28" /></td>
  </tr>
</table>


</body>
</html>
